package com.dhl.state;

import com.dhl.state.sttatepackage.State;
import com.dhl.state.sttatepackage.CanRaffleState;
import com.dhl.state.sttatepackage.DispenseOutState;
import com.dhl.state.sttatepackage.DispenseState;
import com.dhl.state.sttatepackage.NoRaffleState;

/**
 * �齱� //
 * 
 * @author Administrator
 *
 */
public class RaffleActivity {

    /**
     * 活动状态
     */
    State state = null;
    /**
     * 中奖次数
     */
    int count = 0;
    
    // 四个属性表示四个状态
    State noRafflleState = new NoRaffleState(this);
    State canRaffleState = new CanRaffleState(this);
    State dispenseState =   new DispenseState(this);
    State dispensOutState = new DispenseOutState(this);

    /**
     * 1. 初始化状态，设置为不能抽奖状态
     * 2. 初始化奖品数量
     * @param count
     */
    public RaffleActivity( int count) {
        this.state = getNoRafflleState();
        this.count = count;
    }

    /**
     * deductMoney：  扣除积分
     */
    public void debuctMoney(){
        state.deductMoney();
    }

    /**
     * 进行抽奖
     */
    public void raffle(){
    	// 是否中奖
        if(state.raffle()){
        	//改变状态
            state.dispensePrize();
        }
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    /**
     * 奖品数量
     * @return
     */
    public int getCount() {
    	int curCount = count; 
    	count--;
        return curCount;
    }

    public void setCount(int count) {
        this.count = count;
    }

    /**
     * 没有中奖状态
     * @return
     */
    public State getNoRafflleState() {
        return noRafflleState;
    }

    public void setNoRafflleState(State noRafflleState) {
        this.noRafflleState = noRafflleState;
    }

    /**
     * 可以抽奖
     * @return
     */
    public State getCanRaffleState() {
        return canRaffleState;
    }

    public void setCanRaffleState(State canRaffleState) {
        this.canRaffleState = canRaffleState;
    }

    public State getDispenseState() {
        return dispenseState;
    }

    public void setDispenseState(State dispenseState) {
        this.dispenseState = dispenseState;
    }

    public State getDispensOutState() {
        return dispensOutState;
    }

    public void setDispensOutState(State dispensOutState) {
        this.dispensOutState = dispensOutState;
    }
}
